package com.atguigu.gmall.boot.redis.config;




import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


/**
 * @author 陈昆昆
 * @version 1.0
 * @date 2020/6/10 21:06
 */
@Configuration
public class JedisConfigConfig {
   @Value("${spring.redis.host}")
   private String host;

   @Value("${spring.redis.port}")
   private Integer port;
   @Value("${spring.redis.timeout}")
   private Integer timeout;

   @Value("${spring.redis.jedis.pool.max-idle}")
   private Integer maxidle;

   @Value("${spring.redis.jedis.pool.max-active}")
   private Integer maxactive;

   @Value("${spring.redis.jedis.pool.min-idle}")
   private Integer minidle;

    @Bean
    public JedisPool getJedisPool() {
        JedisPoolConfig jedisConfig = new JedisPoolConfig();
        jedisConfig.setMaxIdle(maxidle);
        jedisConfig.setMinIdle(minidle);
        jedisConfig.setMaxTotal(maxactive);
        JedisPool jedisPool = new JedisPool(jedisConfig, host, port, timeout, null);
        return jedisPool;
    }
}
